<script setup lang="ts">
import { getSysDeptList } from "@/views/domain/admin/api/sysDept";
import { computed, onMounted, ref } from "vue";

const props = defineProps<{
  modelValue?: string;
}>();

const emit = defineEmits(["update:modelValue", "change"]);
const deptId = computed({
  get: () => props.modelValue,
  set: value => {
    emit("update:modelValue", value);
    emit("change", value);
  }
});
const deptList = ref([]);
const getDeptList = async () => {
  const { data } = await getSysDeptList({ pageNum: 1, pageSize: 1000 } as any);
  deptList.value = data.list;
};

onMounted(() => {
  getDeptList();
});
</script>

<template>
  <el-select-v2
    v-model="deptId"
    placeholder="请选择部门"
    :options="deptList"
    :props="{
      value: 'id',
      label: 'deptName'
    }"
  />
</template>
<style lang="scss" scoped></style>
